<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.Locale"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.HashSet"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.Set"%>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %>
<%@ page import="com.google.appengine.api.blobstore.BlobstoreService" %>

<html>
    <%
    Locale l = request.getLocale();
    UserService userService = UserServiceFactory.getUserService();
    %>

    <c:choose> 
        <c:when test="${!(empty param.locale)}"> 
            <c:set var="loc" value="${param.locale}"/>
        </c:when> 
        <c:otherwise> 
            <c:set var="loc" value="<%=l%>"/>
        </c:otherwise> 
    </c:choose> 

    <fmt:setLocale value="${loc}" />
    <fmt:bundle basename="messages">
        <head>
            <title><fmt:message key="appTitle"/> <fmt:message key="uploadImage"/></title>
            <link rel="stylesheet" href="./css/index.css" type="text/css" />
            <script language="javascript">
            function doLogin()
            {
            	document.location.href="<%=userService.createLoginURL(request.getRequestURI())%>";
            }
            </script>
        </head>
        <body>
            <h1><fmt:message key="appTitle"/></h1>
            <h2><fmt:message key="uploadImage"/></h2>

            <%
            BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();

  
                User user = userService.getCurrentUser();
                if (user != null) {
            %>
            <p>Hello, <%= user.getNickname() %>! (You can
                <a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>.)</p>

            <form action="<%= blobstoreService.createUploadUrl("/upload") %>" method="post" enctype="multipart/form-data">
                <input type="file" name="file"><br/>
                IdPlace: <input type="text" name="arg0" /><br/>
                Title: <input type="text" name="arg1" /><br/>
                Description: <input type="text" name="arg2" /><br/>
				Media Type: 
				<select name="arg3">
<option value="1">BEFORE</option>
<option value="2">AFTER</option>
<option value="3">NOW</option>
</select>
                Year: <input type="text" name="arg4" value="2001"/><br/>
<br/>
                <input type="submit" value="Submit">
            </form>

            <%
                } else {
            %>
            <button name="submit_button" id="submit_button" style="padding:5px;margin-top:20px;" onclick="doLogin()">
            <img src="http://www.google.com/favicon.ico" alt="Sign in with a Google Account" style="margin-bottom:-3px;">&nbsp; Sign in using your Google Account
          </button>
            </p>
            <%
                }
            %>

        </body>
    </fmt:bundle>
</html>










